package com.lawfinal.controller;


import com.lawfinal.entity.Assistance;
import com.lawfinal.entity.Lawcase;
import com.lawfinal.entity.Lawyerapply;
import com.lawfinal.service.LawyerapplyService;
import com.lawfinal.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 案件详情 前端控制器
 * </p>
 *
 * @author KBr
 * @since 2024-05-08
 */
@RestController
@CrossOrigin("http://localhost:5173/")
@RequestMapping("/lawyerapply")
public class LawyerapplyController {

      @Autowired
      private LawyerapplyService lawyerapplyService;

      //      委托申请  增
      @RequestMapping("/apply")
      public Result apply(@RequestBody Lawyerapply lawyerapply){
            return lawyerapplyService.save(lawyerapply)?Result.sucess():Result.fail();
      }

      @RequestMapping("findByLawyer")
      public Result findByLawyer( String lawyer){
            List list=lawyerapplyService.lambdaQuery().eq(Lawyerapply::getLawyer,lawyer).list();
            return list.size()>0?Result.sucess(list):Result.fail();
      }
      @RequestMapping("findByUser")
      public Result findByUser( String user){
            List list=lawyerapplyService.lambdaQuery().eq(Lawyerapply::getPersona,user).list();
            return list.size()>0?Result.sucess(list):Result.fail();
      }
}
